package service;

import dao.CarDao;
import domain.Car;

import java.sql.SQLException;
import java.util.List;

public class CarService {
    private CarDao carDao = new CarDao();


    //车辆列表
    public List<Car> carList() {
        List<Car> carList = null;
        try {
            carList = carDao.query();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return carList;
    }

    public int insert_car_service(Car car) {
        int result = 0;
        try {
            result = carDao.insert_car(car);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return result;
    }

    public int delete_car_service(Car car) {
        int result = 0;
        try {
            result = carDao.delete_car(car);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return result;
    }

    public int update_car_service(Car car) {
        int result = 0;
        try {
            result = carDao.update_car(car);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return result;
    }

    //用户
    public boolean user_login_service(String username, String password) {
        boolean flag = false;
        try {
            flag = carDao.user_login(username, password);

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return flag;

    }


}
